package file.it.printstream;

import java.io.*;
import java.nio.charset.Charset;

/**
 * 目标：掌握打印流：PrintStream/PrintWriter的用法
 */
public class PrintTest1 {
    public static void main(String[] args) {
        try (
                // 1.创建一个打印流管道
                // PrintStream ps = new PrintStream("src/file/it/printstream/08.txt", String.valueOf(Charset.forName("GBK")));
//                PrintStream ps = new PrintStream("src/file/it/printstream/08.txt");  // 可以写字节

//                PrintWriter ps = new PrintWriter("src/file/it/printstream/08.txt"); // 可以写字符

                // 改成低级流可以追加数据
                PrintWriter ps = new PrintWriter(new FileOutputStream("src/file/it/printstream/08.txt",true));
        ) {
            ps.println(97);
            ps.println('a');
            ps.println("哈哈哈abc");
            ps.println(true);
            ps.println(99.5);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
